<?php /*a:2:{s:62:"/www/wwwroot/cloud_boss/application/admin/view/node/index.html";i:1584974739;s:64:"/www/wwwroot/cloud_boss/application/admin/view/public/basic.html";i:1573743224;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo htmlentities((isset($title) && ($title !== '')?$title:'重庆优合一众')); ?></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/static/plugs/layui/css/layui.css" media="all"/>
    <!--<link rel="stylesheet" href="/static/layuicms/css/index.css" media="all" />-->
    
<link rel="stylesheet" href="/static/css/admin/public.css" media="all"/>

</head>
<body class="<?php echo htmlentities((isset($body) && ($body !== '')?$body:'childrenBody')); ?>">


<!--<?php if(empty($module_list)): ?>-->
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
    <legend>暂无节点信息，可以先刷新节点信息 =》<button class="layui-btn layui-btn-sm refresh_node">刷新节点</button></legend>
</fieldset>
<!--<?php endif; ?>-->

<div class="layui-tab layui-tab-brief" lay-filter="module">
    <ul class="layui-tab-title">
        <?php foreach($module_list as $vo): ?>
        <li <?php if($vo['is_selectd']==true): ?>class="layui-this"<?php endif; ?> lay-id="<?php echo htmlentities($vo['id']); ?>"><?php echo htmlentities((isset($vo['title']) && ($vo['title'] !== '')?$vo['title']:'')); ?>【<?php echo htmlentities((isset($vo['node']) && ($vo['node'] !== '')?$vo['node']:'')); ?>】</li>
        <?php endforeach; ?>
    </ul>
    <div class="layui-tab-content">
        <?php foreach($module_list as $vo): ?>
        <div class="layui-tab-item <?php if($vo['is_selectd']==true): ?>layui-show<?php endif; ?>">
            <table id="<?php echo htmlentities($vo['node']); ?>" lay-filter="<?php echo htmlentities($vo['node']); ?>"></table>
            <script type="text/html" id="checkStatus">
                <input type="checkbox" name="{{d.id}}" value="{{d.is_auth}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="modifyStatus" {{ d.is_auth== 1 ? 'checked' : '' }}>
            </script>
            <!--操作-->
            <script type="text/html" id="userListBar">

                <?php if(auth("$thisClass/del")): ?>
                <a class="layui-btn layui-btn-sm layui-btn-danger" lay-event="del">删除</a>
                <?php endif; ?>

            </script>
        </div>
        <?php endforeach; ?>
    </div>
</div>

<script type="text/javascript" src="/static/plugs/jquery/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="/static/plugs/layui/layui.js"></script>
<script type="text/javascript" src="/static/admin.js"></script>
<script type="text/javascript" src="/static/js/admin/api.js"></script>

<script>
    layui.use(['laydate', 'form', 'layer', 'table', 'laytpl', 'element'], function () {
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laytpl = layui.laytpl,
            table = layui.table,
            laydate = layui.laydate,
            element = layui.element;

        /**<?php foreach($module_list as $vo): ?>**/
        table.render({
            elem: '#<?php echo htmlentities($vo['node']); ?>',
            url: '<?php echo url("$thisClass/index"); ?>?module=<?php echo htmlentities($vo['node']); ?>',
            cellMinWidth: 95,
            height: "full-125",
            limits: [50, 100, 200, 500, 1000],
            limit: 1000,
            id: "node<?php echo htmlentities($vo['node']); ?>",
            cols: [[
                {field: 'node', title: '系统节点', minWidth: 200, align: 'left', sort: true},
                {field: 'title', title: '节点名称', edit: 'text', minWidth: 200, align: "center", style: 'background-color: #009688; color: #fff;', sort: true},
                {field: 'create_at', title: '创建时间', align: 'center', sort: true},
                {field: 'is_auth', title: '节点控制', width: 150, templet: '#checkStatus', unresize: true, align: "center", sort: true},

                /**<?php if(auth("$thisClass/del")): ?>**/
                // {title: '操作', width: 200, templet: '#userListBar', fixed: "right", align: "center"},
                /**<?php endif; ?>**/
            ]]
        });
        /**<?php endforeach; ?>**/

            //Hash地址的定位
        var layid = location.hash.replace(/^#module=/, '');
        element.tabChange('module', layid);

        element.on('tab(module)', function (elem) {
            location.hash = 'module=' + $(this).attr('lay-id');
        });

        //监听启用禁用操作
        form.on('switch(modifyStatus)', function (obj) {
            console.log(this.name);
            $.get('<?php echo url("$thisClass/status"); ?>', {
                id: this.name  //将需要删除的newsId作为参数传入
            }, function (data) {
                console.log(data);
                if (data.code == 0) {
                    layer.msg(data.msg, {icon: 1});
                } else {
                    layer.msg(data.msg, {icon: 2}, function () {
                        window.location.reload();
                    });
                }
            }).error(function () {
                layer.msg('系统错误，请稍后再试', {icon: 2}, function () {
                    tableIns.reload();
                });
            });
            return false;
        });


        //监听单元格字段编辑
        /**<?php foreach($module_list as $vo): ?>**/
        table.on('edit(<?php echo htmlentities($vo['node']); ?>)', function (obj) {
            var value = obj.value //得到修改后的值
                , data = obj.data //得到所在行所有键值
                , field = obj.field; //得到字段
            //弹出loading
            var index = top.layer.msg('数据修改中，请稍候', {icon: 16, time: false, shade: 0.8});
            // 实际使用时的提交信息
            $.post('<?php echo url("$thisClass/index"); ?>', {
                id: data.id,
                field: field,  //修改字段
                value: value,  //修改值
            }, function (res) {
                console.log(res);
                if (res.code == 0) {
                    layer.msg(res.msg, {icon: 1});
                } else {
                    layer.msg(res.msg, {icon: 2}, function () {
                        tableIns.reload();
                    });
                }
            }).error(function () {
                layer.msg('系统错误，请稍后再试', {icon: 2}, function () {
                    tableIns.reload();
                });
            });
            return false;
        });
        /**<?php endforeach; ?>**/


        //列表操作
        /**<?php foreach($module_list as $vo): ?>**/
        table.on('tool(<?php echo htmlentities($vo['node']); ?>)', function (obj) {
            var layEvent = obj.event,
                data = obj.data;
            if (layEvent === 'del') { //删除
                layer.confirm('确定删除此节点？', {icon: 3, title: '提示信息'}, function (index) {
                    $.get('<?php echo url("$thisClass/del"); ?>', {
                        id: data.id  //将需要删除的newsId作为参数传入
                    }, function (data) {
                        console.log(data);
                        if (data.code == 0) {
                            layer.msg(data.msg, {icon: 1}, function () {
                                window.location.reload();
                            });
                        } else {
                            layer.msg(data.msg, {icon: 2});
                        }
                    })
                });
            }
        });
        /**<?php endforeach; ?>**/

        //刷新节点
        $(".refresh_node").click(function () {
            console.log('刷新节点！');
            $.get('<?php echo url("$thisModule/system/refresh_node"); ?>?type=ajax',
                function (data) {
                console.log(data);
                if (data.code == 0) {
                    layer.msg(data.msg, {icon: 1}, function () {
                        window.location.reload();
                    });
                } else {
                    layer.msg(data.msg, {icon: 2});
                }
            })
        })

    });
</script>

</body>
</html>